﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using AbpVueDemo.JichuxinxiDome.WaixieDataManager.Dto;
using AbpVueDemo.JichuxinxinDemo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpVueDemo.JichuxinxiDome.WaixieDataManager
{
    public class WaixieDataService : AsyncCrudAppService<WaixieData, WaixieDataInputDto, int, PageWaixieDataRequestDto, WaixieDataCreateDto, WaixieDataUpdateDto>, IWaixieDataService
    {
        public WaixieDataService(
      IRepository<WaixieData, int> repository) : base(repository)
        {

        }
        /// <summary>
        /// 自定义分页条件查询, 需要重写父类的CreateFilteredQuery方法,让其进行自定义条件筛选
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns></returns>
        protected override IQueryable<WaixieData> CreateFilteredQuery(PageWaixieDataRequestDto input)
        {
            return base.CreateFilteredQuery(input)
               
                 .WhereIf(!string.IsNullOrEmpty(input.w_danweiname), c => c.w_danweiname.Contains(input.w_danweiname))
                  .WhereIf(!string.IsNullOrEmpty(input.w_phone), c => c.w_phone.Contains(input.w_phone));
        }
        //批删
        public async Task<bool> DeleteAll(List<int> ids)
        {
            Repository.Delete(c => ids.Contains(c.Id));
            return true;
        }
    }
}
